import {request, config} from 'utils'
import axios from 'axios'
import FileSaver from 'file-saver'

const {api} = config
const {level} = api

//等级列表
export async function query() {
  const url = `${level}/settingInfo`
  return request({url: url, method: 'get', data: {}})
}

//等级编辑
export async function editGrades(params) {
  const url = `${level}/save`
  return request({url: url, method: 'post', data: params})
}

//启用
export async function open(params) {
  const url = `${level}/open`
  return request({url: url, method: 'put', data: {}})
}

//禁用
export async function close(params) {
  const url = `${level}/close`
  return request({url: url, method: 'put', data: {}})
}

//特权列表
export async function queryPrivileges(params) {
  const url = `${level}/privilege/list`
  return request({url: url, method: 'get', data: {}})
}

//等级特权列表
export async function queryLevelPrivileges({id}) {
  const url = `${level}/setPrivilege/detail/${id}`
  return request({url: url, method: 'get', data: {}})
}

//更新特权配置
export async function updateLevelPrivilege({id, ...params}) {
  const url = `${level}/setPrivilege/update/${id}`
  return request({url: url, method: 'post', data: params})
}

//新增特权配置
export async function addLevelPrivilege(params) {
  const url = `${level}/setPrivilege/create`
  return request({url: url, method: 'post', data: params})
}

//弃用特权配置
export async function removeLevelPrivilege({id}) {
  const url = `${level}/setPrivilege/remove/${id}`
  return request({url: url, method: 'put', data: {}})
}
